#include "Q8_2.h"

int CheckBigger(int a, int b) {return a>b;}
int CheckSmaller(int a, int b) {return a<b;}

void q8_2_run()
{
	cout << "Q8.2\n";
	int a[5] = {1, 5, 3, 2, 4};
	Sort_8_2(a, 5, CheckBigger);
	for(int i=0; i<5; i++)
		cout << a[i] << " ";
}

void Sort_8_2(int *arr, int count, int (*order) (int, int))
{
	for(int i=count-1; i>1; i--)
	{
		for(int j=0; j<i; j++)
		{
			if(order(arr[j], arr[j+1]))
			{
				Swap(arr[j], arr[j+1]);
			}
		}
	}
}

void Swap(int &a, int& b)
{
	int temp = a;
	a = b;
	b = temp;
}